﻿@helper DisplayTime(DateTime date) {
    var now = DateTime.Now;
    if (date.Year != now.Year) {
        @(date.ToShortDateString())
    } else {
        var comp = Math.Abs(date.DayOfYear - now.DayOfYear);
        if (comp >= 7) {
            @(date.ToString("MMM d"))
        } else if (comp >= 2) {
            @(date.ToString("ddd h:mm"))
        } else if (comp == 1) {
            @:Yesterday @(date.ToString("h:mm"))
        }
        else if (Math.Abs(now.Hour - date.Hour) > 0)
        {
            @:Today @(date.ToString("h:mm"))
        }
        else if (Math.Abs(now.Minute - date.Minute) > 0)
        {
            @(Math.Abs(now.Minute - date.Minute)) @: minutes ago
        }
        else
        {
            @:just now
        }
    }
}
